﻿#region Header

/*
Behavioral Rating of Dancing Human Crowds based on Motion Patterns
By

Pascal Hauser 
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

and

Raphael Gfeller
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

*/

#endregion

#region Usings

using Emgu.CV;
using Emgu.CV.Structure;
using paravili.Services;
using paravili.Steps;

#endregion

namespace paravili.CaptureSources {
	/// <summary>
	/// Represents a capture source that gets the images data as a images array pased on the constructor
	/// </summary>
	public class ImagesFromMemoryAsCaptureSource : ICapture, ICaptureSource {
		#region Public Methods

		public ImagesFromMemoryAsCaptureSource(Image<Bgr, byte>[] images) {
			m_images = images;
		}

		#endregion

		#region Private Fields

		private readonly Image<Bgr, byte>[] m_images;
		private int m_index;

		#endregion

		#region ICapture Members

		public Image<Bgr, byte> QueryFrame() {
			return m_images[m_index++ % m_images.Length].Clone();
		}

		public Image<Bgr, byte> QuerySmallFrame() {
			return m_images[m_index++ % m_images.Length].PyrDown();
		}

		#endregion

		#region ICaptureSource Members

		[ConfigurabelStringValue(Name = "Name of the datasource")]
		public string Name { get; set; }

		public Image<Bgr, byte> QueryImage() {
			return QueryFrame();
		}

		public bool IsAvailable {
			get { return m_images.Length > 0; }
		}

		#endregion
	}
}